import 'package:black_movice/config/configs.dart';
import 'package:black_movice/utils/Utils.dart';
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:qr_flutter/qr_flutter.dart';

class Popularize extends StatefulWidget {
  const Popularize({super.key});

  @override
  State<Popularize> createState() => _PopularizeState();
}

class _PopularizeState extends State<Popularize> {
  @override
  Widget build(BuildContext context) {
    return Container(
      constraints:
          BoxConstraints(maxHeight: MediaQuery.of(context).size.height),
      child: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
              width: double.infinity,
              color: Colors.purple,
              child: ExtendedImage.asset(
                "assets/videoImg/popularize.png",
                height: 100.h,
                fit: BoxFit.contain,
              ),
            ),
            Container(
              alignment: Alignment.center,
              padding: EdgeInsets.all(20.w),
              child: Column(
                children: [
                  RichText(
                    text: TextSpan(
                      style: TextStyle(
                          color: Colors.black, fontSize: Configs.titleSize_14),
                      children: [
                        TextSpan(text: "每成功推广"),
                        TextSpan(
                            text: " 1 ", style: TextStyle(color: Colors.red)),
                        TextSpan(text: "人，送五天免广告")
                      ],
                    ),
                  ),
                  // 已推广人数
                  Padding(
                    padding:
                        EdgeInsets.symmetric(vertical: 10.h, horizontal: 0),
                    child: Center(
                      child: Container(
                        decoration: BoxDecoration(
                            border: Border.all(color: Colors.redAccent),
                            borderRadius:
                                BorderRadius.all(Radius.circular(10.sp))),
                        padding: EdgeInsets.symmetric(
                            horizontal: 10.w, vertical: 5.h),
                        child: Text(
                          "已推2两个人",
                          style: TextStyle(color: Colors.redAccent),
                        ),
                      ),
                    ),
                  ),
                  // 推广二维码
                  QrImageView(
                    data: "https://pub.dev/packages/qr_flutter",
                    version: QrVersions.auto,
                    size: 200.w,
                    embeddedImage:
                        ExtendedAssetImageProvider("assets/icon/icon.png"),
                    embeddedImageStyle: QrEmbeddedImageStyle(
                      size: Size(50.w, 50.h),
                    ),
                  ),
                  Text("我的邀请码:10000"),
                  ElevatedButton(
                    onPressed: () {
                      Utils.logDebug("立即分享");
                    },
                    style: ElevatedButton.styleFrom(
                      foregroundColor: Colors.black, // 设置文本颜色
                      backgroundColor: Colors.lightBlueAccent, // 设置背景颜色
                    ),
                    child: const Text("立即分享"),
                  ),
                  Container(
                    padding: EdgeInsets.all(10.h),
                    child: Column(
                      children: [
                        Center(
                          child: Text(
                            "推荐使用浏览器APP扫码。微信、QQ可能会经常屏蔽。",
                            style: TextStyle(
                                color: Colors.red[300],
                                fontSize: Configs.tipSize_10),
                          ),
                        ),
                        Container(
                          alignment: Alignment.centerLeft,
                          padding: EdgeInsets.all(10.sp),
                          width: double.infinity,
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: [
                              Container(
                                alignment: Alignment.centerLeft,
                                width: double.infinity,
                                child: Text(
                                  "推广说明:",
                                  style:
                                      TextStyle(fontSize: Configs.titleSize_14),
                                ),
                              ),
                              Text(
                                "没成功推广1人，送5天免广告，可无限叠加~\n累计推广3人，额外送5天免广告~\n累计推广5人，额外送10天免广告~\n累计推广10人，额外送30天免广告~\n累计推广50人，送终身免广告~",
                                style: TextStyle(fontSize: Configs.textSize_12),
                              ),
                              Container(
                                alignment: Alignment.centerLeft,
                                padding: EdgeInsets.only(top: 10.h),
                                child: Text(
                                  "怎么样算推广成功？",
                                  style: TextStyle(
                                      fontSize: Configs.lgTitleSize_16,
                                      fontWeight: FontWeight.w500),
                                ),
                              ),
                              Container(
                                alignment: Alignment.centerLeft,
                                child: Text(
                                  "分享给未安装过的用户，对方下载后启动应用即可",
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  )
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
